/**
 *
 * User: Zhikang.Peng
 * Date: 2018/08/07 16:05
 */
package lang

import (
	"gitee.com/thghh/jvmgo/native"
	"gitee.com/thghh/jvmgo/rtda"
	"runtime"
)

const jlRuntime = "java/lang/Runtime"

func init() {
	native.Register(jlRuntime, "availableProcessors", "()I", availableProcessors)
}

// public native int availableProcessors();
// ()I
func availableProcessors(frame *rtda.Frame) {
	numCPU := runtime.NumCPU()

	stack := frame.OperandStack()
	stack.PushInt(int32(numCPU))
}
